home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 1998 July / Internet Magazine July 1998.iso / pc / w31maycd / html / java.txt < prev    next >
Encoding:
Text File  |  1998-03-29  |  4.0 KB  |  159 lines

  1.  
  2. Internet Magazine cover CD, May 98 - Java scripts
  3.  
  4.  
  5.  
  6. A bit easier than tediously copying the scripts
  7. printed in the magazine, rather cut and paste the
  8. code below to use in your own Web pages.
  9.  
  10.  
  11. Can it make a cup of coffee and walk the dog...?
  12.  
  13.  
  14. Creating a Timeout
  15. ------------------
  16.  
  17. <BODY BACKGROUND="" BGCOLOR="#ffffff">
  18. <CENTER>
  19. <IMAGE SRC = libya1.jpg WIDTH = 300 HEIGHT = 239>
  20. </CENTER>
  21. <SCRIPT LANGUAGE=JavaScript>
  22. window.setTimeout('location="minute_change2.html";',60000);
  23. </SCRIPT>
  24. </BODY>
  25.  
  26.  
  27. Getting a random number
  28. -----------------------
  29.  
  30. function random(max)
  31. { today=new Date();
  32. áá hour=today.getHours();
  33. áá min=today.getMinutes();
  34. áá sec=today.getSeconds();
  35. áá return(((sec) % max)+1);}
  36.  
  37.  
  38. Creating an array
  39. -----------------
  40.  
  41. function setuparray(num)
  42. { this.length = num;
  43. for (loop=1; loop <= num; loop++);
  44. { this[loop]=0; }
  45. return this;}
  46.  
  47.  
  48. Playing the slideshow
  49. ---------------------
  50.  
  51. <HTML>
  52. <HEAD>
  53. <TITLE>Random slideshow</TITLE>
  54. <SCRIPT Language=JavaScript>
  55. /* Create an array */
  56. function setuparray(num)
  57. { this.length = num;
  58. for (loop=1; loop <= num; loop++);
  59. { this[loop]=0; }
  60. return this;}
  61. /* Get a random number */
  62. function random(max)
  63. { today=new Date();
  64. áá hour=today.getHours();
  65. áá min=today.getMinutes();
  66. áá sec=today.getSeconds();
  67. áá return(((sec) % max)+1);}
  68. function display() 
  69. { picturenum=random(5);
  70. window.setTimeout('location="minute_change3.html"',20010);
  71. document.writeln('<CENTER><IMG SRC='+slideshow[picturenum]+' WIDTH=300 HEIGHT=239></CENTER>');
  72. }
  73. </SCRIPT>
  74. </HEAD>
  75. <BODY BACKGROUND="" BGCOLOR="#ffffff">
  76. <SCRIPT LANGUAGE=JavaScript>
  77. /* Create an array to store addresses of pictures */
  78. slideshow = new setuparray(5);
  79. slideshow[1]="libya1.jpg";
  80. slideshow[2]="libya2.jpg";
  81. slideshow[3]="libya3.jpg";
  82. slideshow[4]="libya4.jpg";
  83. slideshow[5]="libya5.jpg";
  84. display();
  85. </SCRIPT>
  86. </BODY>
  87. </HTML>
  88.  
  89.  
  90. The finishing touches
  91. ---------------------
  92.  
  93. 1
  94.  
  95. <FRAMESET COLS=300,* BORDER=0 FRAMEBORDER=0>
  96. áá <FRAMESET ROWS=225,* BORDER=0 FRAMEBORDER=0>
  97. <FRAME SRC=slideshow1.html MARGINWIDTH=0 
  98. MARGINHEIGHT=0 NAME=picture SCROLLING=NO>
  99. <FRAME SRC=null.html MARGINWIDTH=0 MARGINHEIGHT=0áááá 
  100. NAME=textá SCROLLING=NO>
  101. áá </FRAMESET>
  102. <FRAME SRC=slideshow2.html MARGINWIDTH=0 MARGINHEIGHT=0 NAME=main>
  103. </FRAMESET>
  104.  
  105. 2
  106.  
  107. <HEAD>
  108. <TITLE>A framed slideshow</TITLE>
  109. <SCRIPT Language=JavaScript>
  110. /* Create an array */
  111. function setuparray(num)
  112. { this.length = num;
  113. for (loop=1; loop <= num; loop++);
  114. { this[loop]=0; }
  115. return this;}
  116. /* Get a random number */
  117. function random(max)
  118. { num=0;
  119. á while (num<1||num>max) num=0 + parseInt(Math.random() * max);
  120. á return(num);}
  121. function display() 
  122. /* Get a random number */
  123. { picturenum=0;
  124. while(slideshow[picturenum]==null) picturenum=random(5);
  125. window.setTimeout('location="slideshow1.html"',20010);
  126. /* Display the picture in the array at the position indicated by the random 
  127. number */
  128. parent.text.document.clear();
  129. parent.text.document.writeln('<H2><BR>'+slidetext[picturenum]+'<BR>
  130. </H2>');
  131. document.writeln('<CENTER><IMG SRC='+slideshow[picturenum]+' 
  132. WIDTH=300 HEIGHT=225></CENTER>');
  133. }
  134. </SCRIPT>
  135. </HEAD>
  136. <BODY BACKGROUND="" BGCOLOR="#ffffff">
  137. <SCRIPT LANGUAGE=JavaScript>
  138. /* Create an array to store addresses of pictures */
  139. slideshow = new setuparray(5);
  140. slidetext = new setuparray(5);
  141. /* Load the array with the picture addresses */
  142. slideshow[1]="emiratesbank.jpg";
  143. slideshow[2]="duskboats.jpg";
  144. slideshow[3]="flowers.jpg";
  145. slideshow[4]="fishmarket.jpg";
  146. slideshow[5]="fishroundabout.jpg";
  147. /* Load the text */
  148. slidetext[1]="The glass front of the Emirates Bank is a familiar landmark in Dubai";
  149. slidetext[2]="Passage across the 'Creek' is by tiny passenger boats which ply back and forth until late at night";
  150. slidetext[3]="Although a desert country, careful maintenance ensures Dubai city is always full of flowers";
  151. slidetext[4]="The Arabian Gulf is a rich source of food fish";
  152. slidetext[5]="The fish roundabout is a well known landmark, celebrating the rich food supply of the Gulf";
  153. display();
  154. </SCRIPT>
  155. </BODY>
  156. </HTML>
  157.  
  158.  
  159.